package com.oauth.global.client.ui.extension;

import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.Widget;

public class ExtensionPanel extends Composite {

	private static final Binder binder = GWT.create(Binder.class);

	interface Binder extends UiBinder<Widget, ExtensionPanel> {
	}

	@UiField
	Label name;

	@UiField
	Label description;

	@UiField
	Image extImage;
 
	@UiField
	Button installButton;

	public ExtensionPanel() {
		initWidget(binder.createAndBindUi(this));
	}

	public void setDetails(String name, String description, String imageUrl, final String extUrl) {
		this.name.setText(name);
		this.description.setText(description);
		extImage.setUrl(imageUrl);
		installButton.addClickHandler(new ClickHandler() {

			@Override
			public void onClick(ClickEvent pEvent) {
				Window.open(extUrl, "OAuth-Chrome Extensions", null);
			}
		});

	}

}
